# -*- coding: utf-8 -*-

from django.db import models
from core.models import CoreModel, table_prefix


class OperLog(CoreModel):
    module = models.CharField(
        null=True, blank=True, max_length=64, verbose_name="请求模块"
    )
    path = models.CharField(
        null=True, blank=True, max_length=400, verbose_name="请求地址"
    )
    body = models.TextField(null=True, blank=True, verbose_name="请求参数")
    method = models.CharField(
        null=True, blank=True, max_length=8, verbose_name="请求方式"
    )
    msg = models.TextField(null=True, blank=True, verbose_name="操作说明")
    ip = models.CharField(
        null=True, blank=True, max_length=32, verbose_name="请求ip地址"
    )
    browser = models.CharField(
        null=True, blank=True, max_length=64, verbose_name="请求浏览器"
    )
    code = models.CharField(
        null=True, blank=True, max_length=32, verbose_name="响应状态码"
    )
    os = models.CharField(null=True, blank=True, max_length=64, verbose_name="操作系统")
    result = models.TextField(null=True, blank=True, verbose_name="返回信息")

    class Meta:
        db_table = table_prefix + "system_operlog"
        verbose_name = "操作日志"
        verbose_name_plural = verbose_name
        ordering = ("-create_time",)
